var oa=Object.defineProperty;var ia=(e,t)=>()=>(e&&(t=e(e=0)),t);var aa=(e,t)=>{for(var n in t)oa(e,n,{get:t[n],enumerable:!0})};var ko={};aa(ko,{preCache:()=>nc,snapdom:()=>Y});function ca(e){if(e===!0)return"soft";if(e===!1)return"disabled";if(typeof e=="string"){let t=e.toLowerCase().trim();if(t==="auto")return"auto";if(t==="full")return"full";if(t==="soft"||t==="disabled")return t}return"soft"}function Ur(e="soft"){switch(L.session.__counterEpoch=(L.session.__counterEpoch||0)+1,e){case"auto":{L.session.styleMap=new Map,L.session.nodeMap=new Map;return}case"soft":{L.session.styleMap=new Map,L.session.nodeMap=new Map,L.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{L.session.styleMap=new Map,L.session.nodeMap=new Map,L.session.styleCache=new WeakMap,L.computedStyle=new WeakMap,L.measureHints=new WeakMap,L.baseStyle=new ie(50),L.defaultStyle=new ie(30),L.image=new ie(100),L.background=new ie(100),L.resource=new ie(150),L.font=new Set;return}default:{L.session.styleMap=new Map,L.session.nodeMap=new Map,L.session.styleCache=new WeakMap;return}}}function Nn(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let n=t[2].trim();return n.startsWith("#")?null:n}function ua(e){if(!e||e==="none")return"";let t=e.replace(/translate[XY]?\([^)]*\)/g,"");return t=t.replace(/matrix\(([^)]+)\)/g,(n,r)=>{let o=r.split(",").map(i=>i.trim());return o.length!==6?`matrix(${r})`:(o[4]="0",o[5]="0",`matrix(${o.join(", ")})`)}),t=t.replace(/matrix3d\(([^)]+)\)/g,(n,r)=>{let o=r.split(",").map(i=>i.trim());return o.length!==16?`matrix3d(${r})`:(o[12]="0",o[13]="0",`matrix3d(${o.join(", ")})`)}),t.trim().replace(/\s{2,}/g," ")}function Ft(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function da(e,t){if(!e||/^(data|blob|about|#)/i.test(e.trim()))return e;try{let n=t||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(e,n).href}catch{return e}}function ma(e="[snapDOM]",{ttlMs:t=5*6e4,maxEntries:n=12}={}){let r=new Map,o=0;function i(a,l,c){if(o>=n)return;let s=Date.now();(r.get(l)||0)>s||(r.set(l,s+t),o++,a==="warn"&&console&&console.warn?console.warn(`${e} ${c}`):console&&console.error&&console.error(`${e} ${c}`))}return{warnOnce(a,l){i("warn",a,l)},errorOnce(a,l){i("error",a,l)},reset(){r.clear(),o=0}}}function fa(e){return/^data:|^blob:|^about:blank$/i.test(e)}function pa(e,t){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=t.includes("{url}")?t.split("{url}")[0]:t,o=new URL(r||".",n),i=new URL(e,n);if(i.origin===o.origin)return!0;let a=i.searchParams;if(a&&(a.has("url")||a.has("target")))return!0}catch{}return!1}function ha(e,t){if(!t||fa(e)||pa(e,t))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(e,n);return typeof location<"u"?r.origin!==location.origin:!0}catch{return!!t}}function ga(e,t){if(!t)return e;if(t.includes("{url}"))return t.replace("{urlRaw}",Ft(e)).replace("{url}",encodeURIComponent(e));if(/[?&]url=?$/.test(t))return`${t}${encodeURIComponent(e)}`;if(t.endsWith("?"))return`${t}url=${encodeURIComponent(e)}`;if(t.endsWith("/"))return`${t}${Ft(e)}`;let n=t.includes("?")?"&":"?";return`${t}${n}url=${encodeURIComponent(e)}`}function pr(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||"")),r.onerror=()=>n(new Error("read_failed")),r.readAsDataURL(e)})}function ya(e,t){return[t.as||"blob",t.timeout??3e3,t.useProxy||"",t.errorTTL??8e3,e].join("|")}async function me(e,t={}){let n=t.as??"blob",r=t.timeout??3e3,o=t.useProxy||"",i=t.errorTTL??8e3,a=t.headers||{},l=!!t.silent;if(/^data:/i.test(e))try{if(n==="text")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1,mime:String(e).slice(5).split(";")[0]||""};let[,g="",y=""]=String(e).match(/^data:([^,]*),(.*)$/)||[],b=/;base64/i.test(g)?atob(y):decodeURIComponent(y),S=new Uint8Array([...b].map(E=>E.charCodeAt(0))),w=new Blob([S],{type:(g||"").split(";")[0]||""});return{ok:!0,data:w,status:200,url:e,fromCache:!1,mime:w.type||""}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(e))try{let g=await fetch(e);if(!g.ok)return{ok:!1,data:null,status:g.status,url:e,fromCache:!1,reason:"http_error"};let y=await g.blob(),b=y.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await pr(y),status:g.status,url:e,fromCache:!1,mime:b}:n==="text"?{ok:!0,data:await y.text(),status:g.status,url:e,fromCache:!1,mime:b}:{ok:!0,data:y,status:g.status,url:e,fromCache:!1,mime:b}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(e))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:e,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:e,fromCache:!1};let c=ya(e,{as:n,timeout:r,useProxy:o,errorTTL:i}),s=mt.get(c);if(s&&s.until>Date.now())return{...s.result,fromCache:!0};s&&mt.delete(c);let u=Rt.get(c);if(u)return u;let d=ha(e,o)?ga(e,o):e,m=t.credentials;if(!m)try{let g=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(e,g);m=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{m="omit"}let f=new AbortController,p=setTimeout(()=>f.abort("timeout"),r),h=(async()=>{try{let g=await fetch(d,{signal:f.signal,credentials:m,headers:a});if(!g.ok){let S={ok:!1,data:null,status:g.status,url:d,fromCache:!1,reason:"http_error"};if(i>0&&mt.set(c,{until:Date.now()+i,result:S}),!l){let w=`${g.status} ${g.statusText||""}`.trim();yn.warnOnce(`http:${g.status}:${n}:${new URL(e,location?.href??"http://localhost/").origin}`,`HTTP error ${w} while fetching ${n} ${e}`)}return t.onError&&t.onError(S),S}if(n==="text")return{ok:!0,data:await g.text(),status:g.status,url:d,fromCache:!1};let y=await g.blob(),b=y.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await pr(y),status:g.status,url:d,fromCache:!1,mime:b}:{ok:!0,data:y,status:g.status,url:d,fromCache:!1,mime:b}}catch(g){let y=g&&typeof g=="object"&&"name"in g&&g.name==="AbortError"?String(g.message||"").includes("timeout")?"timeout":"abort":"network",b={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:y};if(!/^blob:/i.test(e)&&i>0&&mt.set(c,{until:Date.now()+i,result:b}),!l){let S=`${y}:${n}:${new URL(e,location?.href??"http://localhost/").origin}`,w=y==="timeout"?`Timeout after ${r}ms. Consider increasing timeout or using a proxy for ${e}`:y==="abort"?`Request aborted while fetching ${n} ${e}`:`Network/CORS issue while fetching ${n} ${e}. A proxy may be required`;yn.errorOnce(S,w)}return t.onError&&t.onError(b),b}finally{clearTimeout(p),Rt.delete(c)}})();return Rt.set(c,h),h}async function Rn(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()==="none")return e;let n=Nn(e);if(!n)return e;let r=da(n),o=Ft(r),i=(t.useProxy||"")+"|"+o;if(L.background.has(i)){let a=L.background.get(i);return a?`url("${a}")`:"none"}try{let a=await me(o,{as:"dataURL",useProxy:t.useProxy});return a.ok?(L.background.set(i,a.data),`url("${a.data}")`):(L.background.set(i,null),"none")}catch{return L.background.set(i,null),"none"}}function wa(){for(let e of zr){let t=String(e).toLowerCase();Dn.has(t)||Ut.has(t)||Vr(t)}}function Vr(e){if(e=String(e).toLowerCase(),Ut.has(e)){let i={};return L.defaultStyle.set(e,i),i}if(L.defaultStyle.has(e))return L.defaultStyle.get(e);let t=document.getElementById("snapdom-sandbox");t||(t=document.createElement("div"),t.id="snapdom-sandbox",t.setAttribute("data-snapdom-sandbox","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="0px",t.style.height="0px",t.style.overflow="hidden",document.body.appendChild(t));let n=document.createElement(e);n.style.all="initial",t.appendChild(n);let r=getComputedStyle(n),o={};for(let i of r){if(Pn(i))continue;let a=r.getPropertyValue(i);o[i]=a}return t.removeChild(n),L.defaultStyle.set(e,o),o}function Pn(e){let t=En.get(e);if(t===void 0){let n=String(e).toLowerCase();t=Gr.has(n)||Yr.test(n)||jr.test(n),En.set(e,t)}return t}function Br(e,t){return!Kr.has(e)&&(t==="inline"||Xr.has(e)||qr.has(e))}function bn(e,t,n=!0,r=!1){if(t=String(t||"").toLowerCase(),Ut.has(t))return"";let o=[],i=Vr(t),a=(e.display||"").toLowerCase(),l=a==="inline",c=Br(t,a)&&n,s=!1;for(let u in e){if(Pn(u))continue;let d=e[u];if(c){if(Zr.has(u))continue;if(Qr.has(u)){d&&d!==i[u]&&(o.push(`${u}:${d}`),d!=="auto"&&(s=!0));continue}}d&&d!==i[u]&&o.push(`${u}:${d}`)}if(c&&!l&&!r&&!s){let u=e.width;u&&u!=="auto"&&u!==i.width&&o.push(`min-width:${u}`)}return o.sort(),o.join(";")}function Ea(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll=="function"&&e.querySelectorAll("*").forEach(n=>t.add(n.tagName.toLowerCase())),Array.from(t))}function Sa(e){let t=new Map;for(let r of e){let o=L.defaultStyle.get(r);if(!o)continue;let i=Object.entries(o).map(([a,l])=>`${a}:${l};`).sort().join("");i&&(t.has(i)||t.set(i,[]),t.get(i).push(r))}let n="";for(let[r,o]of t.entries())n+=`${o.join(",")} { ${r} } `;return n}function xa(e){let t=Array.from(new Set(e.values())).filter(Boolean).sort(),n=new Map,r=1;for(let o of t)n.set(o,`c${r++}`);return n}function va(e){try{let t=e?.ownerDocument;if(!t)return typeof window<"u"?window:null;let n=t.defaultView;if(n&&typeof n.getComputedStyle=="function")return n;if(typeof window<"u"&&window.frames)for(let r=0;r{let i={length:0,getPropertyValue:()=>"",item:()=>""};return i[Symbol.iterator]=function*(){},i};if(!(e instanceof Element)){let i=typeof window<"u"?window:null;if(i&&typeof i.getComputedStyle=="function")try{return i.getComputedStyle(e,t)||n()}catch{return n()}return n()}let r=L.computedStyle.get(e);r||(r=new Map,L.computedStyle.set(e,r));let o=r.get(t);if(!o){let i=va(e),a=null;try{a=i&&typeof i.getComputedStyle=="function"?i.getComputedStyle(e,t):null}catch{}if(!a&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{e.ownerDocument===document&&(a=window.getComputedStyle(e,t))}catch{}o=a||n(),r.set(t,o)}return o}function hr(e){let t={};for(let n of e)t[n]=e.getPropertyValue(n);for(let n of Jr){let r=t[`border-${n}-style`],o=t[`border-${n}-width`];(r==="none"||r==="hidden"||o==="0px")&&(delete t[`border-${n}-style`],delete t[`border-${n}-width`],delete t[`border-${n}-color`])}return t}function wn(e){let t=[],n=0,r=0;for(let o=0;o"u")return!1;if(navigator.userAgentData)return navigator.userAgentData.platform==="iOS";let e=navigator.userAgent||"",t=/iPhone|iPad|iPod/.test(e),n=navigator.maxTouchPoints>2&&/Macintosh/.test(e);return t||n}function ge(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||"",t=e.toLowerCase(),n=t.includes("safari")&&!t.includes("chrome")&&!t.includes("crios")&&!t.includes("fxios")&&!t.includes("android"),r=/applewebkit/i.test(e),o=/mobile/i.test(e),i=!/safari/i.test(e),a=r&&o&&i,l=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(e),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(t),s=/ipad|iphone|ipod/.test(t)&&r;return n||a||l||c||s}function Ta(){if(typeof navigator>"u")return!1;let e=(navigator.userAgent||"").toLowerCase();return e.includes("firefox")||e.includes("fxios")}function B(e,t,n){let r=e&&typeof e=="object"&&(e.options||e);r&&r.debug&&(n!==void 0?console.warn("[snapdom]",t,n):console.warn("[snapdom]",t))}function Ma(e){if(!no(e))return e;try{let t=ro(e),n=t.match(/]*>/i);if(!n)return e;let r=n[0],o=parseFloat((r.match(/\bwidth="([\d.]+)/i)||[])[1]),i=parseFloat((r.match(/\bheight="([\d.]+)/i)||[])[1]);if(!Number.isFinite(o)||!Number.isFinite(i)||o<=0||i<=0)return e;let a=Math.min(1,je/o,je/i,Math.sqrt(On/(o*i)));if(a>=1)return e;let l=Math.max(1,Math.floor(o*a)),c=Math.max(1,Math.floor(i*a));console.warn(`[snapDOM] Capture ${Math.round(o)}\xD7${Math.round(i)}px exceeds the browser image-decode limit (${je}px/side); downscaling to ${l}\xD7${c}px. Lower \`scale\` or set \`width\`/\`height\` to control output size.`);let s=t.replace(r,r.replace(/(\bwidth=")[\d.]+/i,`$1${l}`).replace(/(\bheight=")[\d.]+/i,`$1${c}`));return oo(s)}catch{return e}}function no(e){return typeof e=="string"&&/^data:image\/svg\+xml/i.test(e)}function ro(e){let t=e.indexOf(",");return t>=0?decodeURIComponent(e.slice(t+1)):""}function oo(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function Ca(e){let t=[],n="",r=0;for(let o=0;oo.trim()).filter(Boolean)}function La(e){let t=[],n="",r=0;for(let i=0;i`${l}:${c}`).join(";")}function Ia(e){return e.replace(/([^{}]+)\{([^}]*)\}/g,(t,n,r)=>`${n}{${io(r)}}`)}function ka(e){return e=e.replace(/]*>([\s\S]*?)<\/style>/gi,(t,n)=>t.replace(n,Ia(n))),e=e.replace(/style=(['"])([\s\S]*?)\1/gi,(t,n,r)=>`style=${n}${io(r)}${n}`),e}function Na(e){if(!ge()||!no(e))return e;try{let t=ro(e),n=ka(t);return oo(n)}catch{return e}}async function Vt(e,t){let{width:n,height:r,scale:o=1,dpr:i=1,meta:a={},backgroundColor:l}=t;e=Na(e),e=Ma(e);let c=new Image;if(c.loading="eager",c.decoding="sync",c.crossOrigin="anonymous",c.src=e,await c.decode(),ge()){c.style.cssText="position:fixed;left:-99999px;top:-99999px;pointer-events:none",document.body.appendChild(c);try{await new Promise(A=>requestAnimationFrame(()=>requestAnimationFrame(A)))}finally{try{c.remove()}catch{}}}let s=c.naturalWidth,u=c.naturalHeight,d=Number.isFinite(a.w0)?a.w0:s,m=Number.isFinite(a.h0)?a.h0:u,f,p,h=Number.isFinite(n),g=Number.isFinite(r);if(h&&g)f=Math.max(1,n),p=Math.max(1,r);else if(h){let A=n/Math.max(1,d);f=n,p=m*A}else if(g){let A=r/Math.max(1,m);p=r,f=d*A}else f=s,p=u;f=f*o,p=p*o;let y=f*i,b=p*i,S=Math.max(y/je,b/je,Math.sqrt(y*b/On));S>1&&(console.warn(`[snapDOM] Output ${Math.round(y)}\xD7${Math.round(b)}px exceeds the browser canvas limit (${je}px/side); downscaling. Lower \`scale\`/\`dpr\` or set \`width\`/\`height\`.`),f/=S,p/=S);let w=document.createElement("canvas");w.width=f*i,w.height=p*i,w.style.width=`${f}px`,w.style.height=`${p}px`;let E=w.getContext("2d");return i!==1&&E.scale(i,i),l&&(E.save(),E.fillStyle=l,E.fillRect(0,0,f,p),E.restore()),E.drawImage(c,0,0,f,p),w}async function ao(e,t){let n=await Vt(e,t),r=new Image;return r.src=n.toDataURL(`image/${t.format}`,t.quality),await r.decode(),r.style.width=`${n.width/t.dpr}px`,r.style.height=`${n.height/t.dpr}px`,r}async function gr(e,t){let{scale:n=1,width:r,height:o,meta:i={}}=t,a=Number.isFinite(r),l=Number.isFinite(o),c=Number.isFinite(n)&&n!==1||a||l;if(ge()&&c)return await ao(e,{...t,format:"png",quality:1,meta:i});let s=new Image;if(s.decoding="sync",s.loading="eager",s.src=e,await s.decode(),a&&l)s.style.width=`${r}px`,s.style.height=`${o}px`;else if(a){let u=Number.isFinite(i.w0)?i.w0:s.naturalWidth,d=Number.isFinite(i.h0)?i.h0:s.naturalHeight,m=r/Math.max(1,u);s.style.width=`${r}px`,s.style.height=`${Math.round(d*m)}px`}else if(l){let u=Number.isFinite(i.w0)?i.w0:s.naturalWidth,d=Number.isFinite(i.h0)?i.h0:s.naturalHeight,m=o/Math.max(1,d);s.style.height=`${o}px`,s.style.width=`${Math.round(u*m)}px`}else{let u=Math.round(s.naturalWidth*n),d=Math.round(s.naturalHeight*n);if(s.style.width=`${u}px`,s.style.height=`${d}px`,typeof e=="string"&&e.startsWith("data:image/svg+xml"))try{let m=decodeURIComponent(e.split(",")[1]).replace(/width="[^"]*"/,`width="${u}"`).replace(/height="[^"]*"/,`height="${d}"`);e=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,s.src=e}catch(m){B(t,"SVG width/height patch in toImg failed",m)}}return s}async function so(e,t){let n=t.type;if(n==="svg"){let o=decodeURIComponent(e.split(",")[1]);return new Blob([o],{type:"image/svg+xml"})}let r=await Vt(e,t);return new Promise(o=>r.toBlob(i=>o(i),`image/${n}`,t.quality))}async function br(e,t){let n=new File([e],t,{type:e.type});if(!navigator.canShare?.({files:[n]}))return!1;try{await navigator.share({files:[n],title:t})}catch(r){if(r.name!=="AbortError")return!1}return!0}async function Ra(e,t){let n=new Set(["png","jpeg","jpg","webp","svg"]),r=(t?.type||"").toLowerCase(),o=n.has(r)?r:"",i=(t?.format||o||"").toLowerCase(),a=i==="jpg"?"jpeg":i||"png",l=t?.filename||`snapdom.${a}`,c={...t||{},format:a,type:a};c.dpr=1;let s=Aa();if(a==="svg"){let m=await so(e,{...c,type:"svg"});if(s&&await br(m,l))return;let f=URL.createObjectURL(m),p=document.createElement("a");p.href=f,p.download=l,document.body.appendChild(p),p.click(),URL.revokeObjectURL(f),p.remove();return}let u=await Vt(e,c);if(s){let m=`image/${a}`,f=await new Promise(p=>u.toBlob(p,m,t?.quality));if(f&&await br(f,l))return}let d=document.createElement("a");d.href=u.toDataURL(`image/${a}`,t?.quality),d.download=l,document.body.appendChild(d),d.click(),d.remove()}function ft(){xn++,ht.size>Da&&ht.clear()}function _a(e=document.documentElement){if(!Er){Er=!0;try{new MutationObserver(()=>ft()).observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>ft()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let t=document.fonts;t&&(t.addEventListener?.("loadingdone",ft),t.ready?.then(()=>ft()).catch(()=>{}))}catch{}}}function Oa(e,t={}){let n={},r=e.getPropertyValue("visibility"),o=t.excludeStyleProps;for(let d=0;dn[0]r[0]?1:0).map(([n,r])=>`${n}:${r}`).join(";"),Sr.set(e,t),t)}function Ha(e,t=null,n={}){let r=wr.get(e),o=!!(n&&n.embedFonts),i=n&&n.excludeStyleProps||null;if(r&&r.epoch===xn&&r.embedFonts===o&&r.excludeStyleProps===i)return r.snapshot;let a=t||getComputedStyle(e),l=Oa(a,n);return ja(e,a,l),wr.set(e,{epoch:xn,snapshot:l,embedFonts:o,excludeStyleProps:i}),l}function Wa(e,t){return e&&e.session&&e.persist?e:e&&(e.styleMap||e.styleCache||e.nodeMap)?{session:e,persist:{snapshotKeyCache:ht,defaultStyle:L.defaultStyle,baseStyle:L.baseStyle,image:L.image,resource:L.resource,background:L.background,font:L.font},options:t||{}}:{session:L.session,persist:{snapshotKeyCache:ht,defaultStyle:L.defaultStyle,baseStyle:L.baseStyle,image:L.image,resource:L.resource,background:L.background,font:L.font},options:e||t||{}}}function Ua(e,t,n){if(!(!e.style||e.style.length===0))for(let r=0;r0||(parseFloat(e.borderBottomWidth)||0)>0||(parseFloat(e.paddingTop)||0)>0||(parseFloat(e.paddingBottom)||0)>0?!0:(e.overflowBlock||e.overflowY||"visible")!=="visible"}function mo(e){let t=e.parentElement;if(!t)return!1;let n=ce(t).display||"";return n.includes("flex")||n.includes("grid")}function za(e,t){if(e.textContent&&/\S/.test(e.textContent))return!0;let n=e.firstElementChild,r=e.lastElementChild;if(n&&n.tagName==="BR"||r&&r.tagName==="BR")return!0;let o=e.scrollHeight;if(o===0)return!1;let i=parseFloat(t.paddingTop)||0,a=parseFloat(t.paddingBottom)||0;return o>i+a}function ja(e,t,n){if(e instanceof HTMLElement&&e.style&&e.style.height)return;let r=e.tagName&&e.tagName.toLowerCase();if(!r||!["div","section","article","main","aside","header","footer","nav"].includes(r))return;let o=parseFloat(t.height);if(Number.isFinite(o)&&e.scrollHeight>0&&Math.abs(o-e.scrollHeight)>2||t.aspectRatio&&t.aspectRatio!=="none"&&t.aspectRatio!=="auto")return;let i=t.display||"";if(i.includes("flex")||i.includes("grid")||Va(e))return;let a=t.position;if(a==="absolute"||a==="fixed"||a==="sticky"||t.transform!=="none"||Ba(t)||mo(e))return;let l=t.overflowX||t.overflow||"visible",c=t.overflowY||t.overflow||"visible";if(l!=="visible"||c!=="visible")return;let s=t.clip;s&&s!=="auto"&&s!=="rect(auto, auto, auto, auto)"||t.visibility==="hidden"||t.opacity==="0"||za(e,t)&&(delete n.height,delete n["block-size"])}function vn(e){let t=e;for(;t&&t.nodeType===1;){if(t.namespaceURI==="http://www.w3.org/2000/svg"&&Ya.has(t.localName))return!0;t=t.parentNode}return!1}function Ga(e,t){let n=t+"::"+e.toLowerCase(),r=xr.get(n);if(r)return r;let o=document,i=t==="http://www.w3.org/2000/svg"?o.createElementNS(t,e):o.createElement(e),a=o.createElement("div");a.style.cssText="position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;",a.appendChild(i),o.documentElement.appendChild(a);let l=getComputedStyle(i),c={};for(let s of fo)c[s]=l.getPropertyValue(s)||"";return a.remove(),xr.set(n,c),c}function Xa(e,t){if(!(e instanceof Element)||!(t instanceof Element)||vn(e))return;let n=e.getAttribute?.("style"),r=!!(n&&n.includes("var("));if(!r&&e.attributes?.length){let i=e.attributes;for(let a=0;anew Promise(o=>{function i(){ze(a=>{!(a&&typeof a.timeRemaining=="function")||a.timeRemaining()>0?t(r,o):i()},{fast:n})}i()})))}function qa(e){return e=e.trim(),!e||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(e)?e:`${e}:not([data-sd-slotted])`}function Ka(e,t,n=!0){return e.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{if(r.startsWith(":where(")||r.startsWith("@"))return r;let o=n?qa(r):r;return`:where(${t} ${o})`}).join(", ")}function Za(e,t){return e?(e=e.replace(/:host\(([^)]+)\)/g,(n,r)=>`:where(${t}:is(${r.trim()}))`),e=e.replace(/:host\b/g,`:where(${t})`),e=e.replace(/:host-context\(([^)]+)\)/g,(n,r)=>`:where(:where(${r.trim()}) ${t})`),e=e.replace(/::slotted\(([^)]+)\)/g,(n,r)=>`:where(${t} ${r.trim()})`),e=e.replace(/(^|})(\s*)([^@}{]+){/g,(n,r,o,i)=>{let a=Ka(i,t,!0);return`${r}${o}${a}{`}),e):""}function Qa(e){return e.shadowScopeSeq=(e.shadowScopeSeq||0)+1,`s${e.shadowScopeSeq}`}function Ja(e){let t="";try{e.querySelectorAll("style").forEach(r=>{t+=(r.textContent||"")+` `});let n=e.adoptedStyleSheets||[];for(let r of n)try{if(r&&r.cssRules)for(let o of r.cssRules)t+=o.cssText+` `}catch{}}catch{}return t}function el(e,t,n){if(!t)return;let r=document.createElement("style");r.setAttribute("data-sd",n),r.textContent=t,e.insertBefore(r,e.firstChild||null)}function tl(e,t){try{let n=e.currentSrc||e.src||"";if(!n)return;t.setAttribute("src",n),t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.loading="eager",t.decoding="sync"}catch{}}function nl(e){let t=new Set;if(!e)return t;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,r;for(;r=n.exec(e);)t.add(r[1]);return t}function rl(e,t){try{let n=getComputedStyle(e).getPropertyValue(t).trim();if(n)return n}catch{}try{let n=getComputedStyle(document.documentElement).getPropertyValue(t).trim();if(n)return n}catch{}return""}function ol(e,t,n){let r=[];for(let o of t){let i=rl(e,o);i&&r.push(`${o}: ${i};`)}return r.length?`${n}{${r.join("")}} `:""}function il(e){e&&(e.nodeType===Node.ELEMENT_NODE&&e.setAttribute("data-sd-slotted",""),e.querySelectorAll&&e.querySelectorAll("*").forEach(t=>t.setAttribute("data-sd-slotted","")))}async function al(e,t=3){let n=()=>{try{return e.contentDocument||e.contentWindow?.document||null}catch{return null}},r=n(),o=0;for(;osetTimeout(i,0)),r=n(),o++;return r&&(r.body||r.documentElement)?r:null}function ll(e){let t=e.getBoundingClientRect(),n=0,r=0,o=0,i=0;try{let c=getComputedStyle(e);n=parseFloat(c.borderLeftWidth)||0,r=parseFloat(c.borderRightWidth)||0,o=parseFloat(c.borderTopWidth)||0,i=parseFloat(c.borderBottomWidth)||0}catch{}let a=Math.max(0,Math.round(t.width-(n+r))),l=Math.max(0,Math.round(t.height-(o+i)));return{contentWidth:a,contentHeight:l,rect:t}}function Ce(e){let t=0,n=0;if(e.offsetWidth>0&&(t=e.offsetWidth),e.offsetHeight>0&&(n=e.offsetHeight),t===0||n===0)try{let r=getComputedStyle(e);if(t===0){let o=parseFloat(r.width);!isNaN(o)&&o>0&&(t=o)}if(n===0){let o=parseFloat(r.height);!isNaN(o)&&o>0&&(n=o)}}catch{}if(t===0||n===0)try{if(t===0){let r=parseFloat(e.getAttribute("width"));!isNaN(r)&&r>0&&(t=r)}if(n===0){let r=parseFloat(e.getAttribute("height"));!isNaN(r)&&r>0&&(n=r)}}catch{}if((t===0||n===0)&&(e.naturalWidth||e.naturalHeight))try{t===0&&e.naturalWidth>0&&(t=e.naturalWidth),n===0&&e.naturalHeight>0&&(n=e.naturalHeight)}catch{}return{width:t,height:n}}function sl(e,t,n){let r=e.defaultView,o=r?r.scrollX:0,i=r?r.scrollY:0,a=e.body?e.body.scrollLeft:0,l=e.body?e.body.scrollTop:0,c=e.documentElement?e.documentElement.scrollLeft:0,s=e.documentElement?e.documentElement.scrollTop:0,u=e.createElement("style");return u.setAttribute("data-sd-iframe-pin",""),u.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${t}px !important;height: ${n}px !important;min-width: ${t}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(e.head||e.documentElement).appendChild(u),()=>{try{u.remove()}catch{}try{r&&typeof r.scrollTo=="function"&&r.scrollTo(o,i),e.body&&(e.body.scrollLeft=a,e.body.scrollTop=l),e.documentElement&&(e.documentElement.scrollLeft=c,e.documentElement.scrollTop=s)}catch{}}}async function cl(e,t,n){let r=await al(e,3);if(!r)throw new Error("iframe document not accessible/ready");let{contentWidth:o,contentHeight:i,rect:a}=ll(e),l=n?.snap;if(!l&&typeof window<"u"&&window.snapdom&&(l=window.snapdom),!l||typeof l.toPng!="function")throw new Error("[snapdom] iframe capture requires snapdom.toPng. Use snapdom(el) or pass options.snap. With ESM, assign window.snapdom = snapdom after import if using iframes.");let c={...n,scale:1},s=sl(r,o,i),u=L.session.nodeMap,d=L.session.styleMap,m=L.session.styleCache,f;try{f=await l.toPng(r.documentElement,c)}finally{s(),L.session.nodeMap=u,L.session.styleMap=d,L.session.styleCache=m}f.style.display="block",f.style.width=`${o}px`,f.style.height=`${i}px`;let p=document.createElement("div");return t.nodeMap.set(p,e),_e(e,p,t,n),p.style.overflow="hidden",p.style.display="block",p.style.width||(p.style.width=`${Math.round(a.width)}px`),p.style.height||(p.style.height=`${Math.round(a.height)}px`),p.appendChild(f),p}function ul(e){let{width:t,height:n}=Ce(e),r=e.getBoundingClientRect(),o;try{o=window.getComputedStyle(e)}catch{}let i=o?parseFloat(o.width):NaN,a=o?parseFloat(o.height):NaN,l=Math.round(t||r.width||0),c=Math.round(n||r.height||0),s=Number.isFinite(i)&&i>0?Math.round(i):Math.max(12,l||16),u=Number.isFinite(a)&&a>0?Math.round(a):Math.max(12,c||16),d=(e.type||"text").toLowerCase()==="checkbox",m=!!e.checked,f=!!e.indeterminate,p=Math.max(Math.min(s,u),12),h="middle";try{o&&o.verticalAlign&&(h=o.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement",e.type||"checkbox"),g.style.cssText=`display:inline-block;width:${p}px;height:${p}px;vertical-align:${h};flex-shrink:0;line-height:0;`;let y=document.createElementNS("http://www.w3.org/2000/svg","svg");y.setAttribute("width",String(p)),y.setAttribute("height",String(p)),y.setAttribute("viewBox",`0 0 ${p} ${p}`),g.appendChild(y);function b(){let S="#0a6ed1";try{o&&(S=o.accentColor||o.color||S)}catch{}let w=2,E=w/2,A=p-w;if(y.innerHTML="",d){let x=document.createElementNS("http://www.w3.org/2000/svg","rect");if(x.setAttribute("x",String(E)),x.setAttribute("y",String(E)),x.setAttribute("width",String(A)),x.setAttribute("height",String(A)),x.setAttribute("rx","2"),x.setAttribute("ry","2"),x.setAttribute("fill",m?S:"none"),x.setAttribute("stroke",S),x.setAttribute("stroke-width",String(w)),y.appendChild(x),m){let M=document.createElementNS("http://www.w3.org/2000/svg","path");M.setAttribute("d",`M ${E+2} ${p/2} L ${p/2-1} ${p-E-2} L ${p-E-2} ${E+2}`),M.setAttribute("stroke","white"),M.setAttribute("stroke-width",String(Math.max(1.5,w))),M.setAttribute("fill","none"),M.setAttribute("stroke-linecap","round"),M.setAttribute("stroke-linejoin","round"),y.appendChild(M)}else if(f){let M=document.createElementNS("http://www.w3.org/2000/svg","rect"),k=Math.max(6,A-4);M.setAttribute("x",String((p-k)/2)),M.setAttribute("y",String((p-w)/2)),M.setAttribute("width",String(k)),M.setAttribute("height",String(w)),M.setAttribute("fill",S),M.setAttribute("rx","1"),y.appendChild(M)}}else{let x=document.createElementNS("http://www.w3.org/2000/svg","circle");if(x.setAttribute("cx",String(p/2)),x.setAttribute("cy",String(p/2)),x.setAttribute("r",String((p-w)/2)),x.setAttribute("fill",m?S:"none"),x.setAttribute("stroke",S),x.setAttribute("stroke-width",String(w)),y.appendChild(x),m){let M=document.createElementNS("http://www.w3.org/2000/svg","circle"),k=Math.max(2,(p-w*2)*.35);M.setAttribute("cx",String(p/2)),M.setAttribute("cy",String(p/2)),M.setAttribute("r",String(k)),M.setAttribute("fill","white"),y.appendChild(M)}}g.style.setProperty("width",`${p}px`,"important"),g.style.setProperty("height",`${p}px`,"important"),g.style.setProperty("min-width",`${p}px`,"important"),g.style.setProperty("min-height",`${p}px`,"important")}return b(),{el:g,applyVisual:b}}async function pt(e){if(L.resource?.has(e))return L.resource.get(e);if(dt.has(e))return dt.get(e);let t=(async()=>{let n=await me(e,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${e}`);return L.resource?.set(e,n.data),n.data})();dt.set(e,t);try{let n=await t;return dt.set(e,n),n}catch(n){throw dt.delete(e),n}}async function vr(e){if(!e||e.indexOf("blob:")===-1)return e;let t=Array.from(new Set(e.match(dl)||[]));if(t.length===0)return e;let n=e;for(let r of t)try{let o=await pt(r);n=n.split(r).join(o)}catch{}return n}function Nt(e){return typeof e=="string"&&e.startsWith("blob:")}function ml(e){return(e||"").split(",").map(t=>t.trim()).filter(Boolean).map(t=>{let n=t.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function fl(e){return e.map(t=>t.desc?`${t.url} ${t.desc.trim()}`:t.url).join(", ")}async function pl(e,t=null){if(!e)return;let n=t,r=e.querySelectorAll?e.querySelectorAll("img"):[];for(let c of r)try{let s=c.getAttribute("src")||c.currentSrc||"";if(Nt(s)){let d=await pt(s);c.setAttribute("src",d)}let u=c.getAttribute("srcset");if(u&&u.includes("blob:")){let d=ml(u),m=!1;for(let f of d)if(Nt(f.url))try{f.url=await pt(f.url),m=!0}catch(p){B(n,"blobUrlToDataUrl for srcset item failed",p)}m&&c.setAttribute("srcset",fl(d))}}catch(s){B(n,"resolveBlobUrls for img failed",s)}let o=e.querySelectorAll?e.querySelectorAll("image"):[];for(let c of o)try{let s="http://www.w3.org/1999/xlink",u=c.getAttribute("href")||c.getAttributeNS?.(s,"href");if(Nt(u)){let d=await pt(u);c.setAttribute("href",d),c.removeAttributeNS?.(s,"href")}}catch(s){B(n,"resolveBlobUrls for SVG image href failed",s)}let i=e.querySelectorAll?e.querySelectorAll("[style*='blob:']"):[];for(let c of i)try{let s=c.getAttribute("style");if(s&&s.includes("blob:")){let u=await vr(s);c.setAttribute("style",u)}}catch(s){B(n,"replaceBlobUrls in inline style failed",s)}let a=e.querySelectorAll?e.querySelectorAll("style"):[];for(let c of a)try{let s=c.textContent||"";s.includes("blob:")&&(c.textContent=await vr(s))}catch(s){B(n,"replaceBlobUrls in style tag failed",s)}let l=["poster"];for(let c of l){let s=e.querySelectorAll?e.querySelectorAll(`[${c}^='blob:']`):[];for(let u of s)try{let d=u.getAttribute(c);Nt(d)&&u.setAttribute(c,await pt(d))}catch(d){B(n,`resolveBlobUrls for ${c} failed`,d)}}}function hn(e){let{width:t,height:n}=Ce(e),r=t,o=n;if(!r||!o){let a=e.getBoundingClientRect();r=r||a.width||0,o=o||a.height||0}let i=document.createElement("div");return i.style.cssText=`display:inline-block;width:${r}px;height:${o}px;visibility:hidden;`,i}async function _t(e,t,n){if(!e)throw new Error("Invalid node");let r=new Set,o=null,i=null;if(e.nodeType===Node.ELEMENT_NODE){let u=(e.localName||e.tagName||"").toLowerCase();if(e.id==="snapdom-sandbox"||e.hasAttribute("data-snapdom-sandbox")||Dn.has(u))return null;if(u==="foreignobject"&&e.parentElement?.closest?.("foreignObject"))return B(t,"Nested skipped (SVG spec limitation \u2014 not rendered by browsers)"),null}if(e.nodeType===Node.TEXT_NODE||e.nodeType!==Node.ELEMENT_NODE)return e.cloneNode(!0);if(e.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide")return hn(e);if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let u of n.exclude)try{if(e.matches?.(u)){if(n.excludeMode==="hide")return hn(e);if(n.excludeMode==="remove")return null}}catch(d){console.warn(`Invalid selector in exclude option: ${u}`,d)}if(typeof n.filter=="function")try{if(!n.filter(e)){if(n.filterMode==="hide")return hn(e);if(n.filterMode==="remove")return null}}catch(u){console.warn("Error in filter function:",u)}if(e.tagName==="IFRAME"){let u=!1;try{u=!!(e.contentDocument||e.contentWindow?.document)}catch(d){B(t,"iframe same-origin probe failed",d)}if(u)try{return await cl(e,t,n)}catch(d){console.warn("[SnapDOM] iframe rasterization failed, fallback:",d)}if(u||console.warn("[snapdom] cross-origin